package com.xiaoze.question.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xiaoze.common.utils.DateUtils;
import com.xiaoze.question.domain.QuestionAnswer;
import com.xiaoze.question.mapper.QuestionAnswerMapper;
import com.xiaoze.question.service.IQuestionAnswerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

/**
 * 试题题目选项管理Service业务层处理
 *
 * @author 胡昊泽
 * @date 2024-08-02
 */
@Service
public class QuestionAnswerServiceImpl extends ServiceImpl<QuestionAnswerMapper, QuestionAnswer> implements IQuestionAnswerService {
    @Autowired
    private QuestionAnswerMapper questionAnswerMapper;

    /**
     * 查询试题题目选项管理
     *
     * @param id 试题题目选项管理ID
     * @return 试题题目选项管理
     */
    @Override
    public QuestionAnswer selectQuestionAnswerById(Long id) {
        return questionAnswerMapper.selectQuestionAnswerById(id);
    }

    /**
     * 查询试题题目选项管理列表
     *
     * @param questionAnswer 试题题目选项管理
     * @return 试题题目选项管理
     */
    @Override
    public List<QuestionAnswer> selectQuestionAnswerList(QuestionAnswer questionAnswer) {
        return questionAnswerMapper.selectQuestionAnswerList(questionAnswer);
    }

    /**
     * 新增试题题目选项管理
     *
     * @param questionAnswer 试题题目选项管理
     * @return 结果
     */
    @Override
    public int insertQuestionAnswer(QuestionAnswer questionAnswer) {
        questionAnswer.setCreateTime(DateUtils.getNowDate());
        questionAnswer.setUnCode(UUID.randomUUID().toString().replace("-",""));
        return questionAnswerMapper.insertQuestionAnswer(questionAnswer);
    }

    /**
     * 修改试题题目选项管理
     *
     * @param questionAnswer 试题题目选项管理
     * @return 结果
     */
    @Override
    public int updateQuestionAnswer(QuestionAnswer questionAnswer) {
        questionAnswer.setUpdateTime(DateUtils.getNowDate());
        return questionAnswerMapper.updateQuestionAnswer(questionAnswer);
    }

    /**
     * 批量删除试题题目选项管理
     *
     * @param ids 需要删除的试题题目选项管理ID
     * @return 结果
     */
    @Override
    public int deleteQuestionAnswerByIds(Long[] ids) {
        return questionAnswerMapper.deleteQuestionAnswerByIds(ids);
    }

    /**
     * 删除试题题目选项管理信息
     *
     * @param id 试题题目选项管理ID
     * @return 结果
     */
    @Override
    public int deleteQuestionAnswerById(Long id) {
        return questionAnswerMapper.deleteQuestionAnswerById(id);
    }
}
